home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Snippets / Platforms & Tools / MacApp / Windoid 1.0b2.2 / UWindoid.h < prev    next >
Encoding:
Text File  |  1991-09-04  |  5.7 KB  |  196 lines  |  [TEXT/MPS ]

  1. // UWindoid.h -----------------------------------------------------------------
  2. // Copyright © 1991 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #pragma once
  5.  
  6.  
  7. // INCLUDE FILES --------------------------------------------------------------
  8.  
  9. #include "IncludeFiles.h"
  10.  
  11.  
  12. //FORWARD DECLARATIONS --------------------------------------------------------
  13.  
  14. class TFloatingMenu;
  15. class TDefaultView;
  16. class TLightPalette;
  17.  
  18.  
  19. // GLOBALS --------------------------------------------------------------------
  20.  
  21. TFloatingMenu*     gFloatingMenu;
  22. TWindow*        gFloatMenuWindow;
  23.  
  24. enum eLights {kGreen=0,kYellow,kRed, kNoTool = 42}; // global values for the lights    
  25.  
  26.  
  27. // CLASS DEFINITIONS-----------------------------------------------------------
  28.  
  29. // TApplication ---------------------------------------------------------------
  30.  
  31. class TWindoidApplication : public TApplication {
  32. public:
  33. //    METHODS
  34.     virtual pascal void         IWindoidApplication(OSType itsMainFileType,
  35.                                                     OSType itsCreator);
  36.     virtual pascal void            DoSetupMenus();
  37.     virtual pascal TDocument*     DoMakeDocument(CommandNumber, TFile* itsFile);
  38. };
  39.  
  40.  
  41. // TDocuments -----------------------------------------------------------------
  42.  
  43. class TWindoidDocument : public TDocument {
  44. public:
  45. //    METHODS
  46.     virtual pascal void DoMakeViews(Boolean forPrinting); 
  47.  
  48.     virtual pascal void    DoSetupMenus();                // setup document menus
  49.     virtual pascal void DoMenuCommand(CommandNumber aCommandNumber);
  50.     virtual pascal void DoLight(eLights);            // do Light drawing
  51.  
  52. //    FIELDS    
  53.     TDefaultView*        fView;                        // the view used     
  54. };
  55.  
  56.  
  57. // TViews ---------------------------------------------------------------------
  58.  
  59. class TDefaultView : public TView {
  60. public:
  61. //    ENUMS AND TYPEDEFS
  62.     enum eCoordinate {ktop=20,kbottom=150,kleft=200,kright=250};
  63.  
  64. //    METHODS
  65.     virtual pascal void        Initialize();
  66.     
  67.     virtual pascal void     Draw(const VRect& area);// general draw method
  68.     virtual pascal void     DrawTrafficLight();        // draw traffic light body
  69.     virtual pascal void     DrawLight();            // general light drawing method
  70.     virtual pascal void     DrawGreen();            // draw green light
  71.     virtual pascal void     DrawYellow();            // draw yellow light
  72.     virtual pascal void     DrawRed();                // draw red light
  73.  
  74. //    FIELDS    
  75.     Rect     fTrafficRect;                            // traffic light components
  76.     Rect     fBlackTopRect;
  77.     Rect     fTrafficLightFrame;
  78.     Rect     fGreenRect;
  79.     Rect     fYellowRect;
  80.     Rect     fRedRect;
  81.     Str255     fTitle;
  82.     eLights    fCurrentLight;
  83. };
  84.  
  85.  
  86. // And now the cool stuff, the TearOff floating window class
  87.  
  88. class TFloatingMenu : public TTearOffMenuView {
  89. public:
  90. //    METHODS
  91.     virtual pascal void IFloatingMenu();        // init floating menu
  92. };
  93.  
  94.  
  95. class TLightPalette : public TView {
  96. public:
  97. //    METHODS
  98.     virtual pascal void ILightPalette(TDocument *itsDocument, TView *itsView);
  99.     
  100.     virtual pascal void Draw(const VRect &area);    // draw view
  101.     virtual pascal void Activate(Boolean entering);    // activate view
  102.     virtual pascal void IRes(TDocument* itsDocument, TView* itsSuperView,
  103.                             TStream* itsParams);
  104.     
  105.     virtual pascal void DoMouseCommand       (VPoint& theMouse, TToolboxEvent* event,
  106.                                             Point hysteresis);
  107.                                             
  108.     virtual pascal void TrackFeedback       (TrackPhase         aTrackPhase,
  109.                                             const VPoint&    anchorPoint,
  110.                                             const VPoint&    previousPoint,
  111.                                             const VPoint&    nextPoint,
  112.                                             Boolean            mouseDidMove,
  113.                                             Boolean            turnItOn);
  114.  
  115.     
  116.     virtual pascal void SelectNewTool(eLights whichTool);
  117.     virtual pascal void FrameTool(Rect&);            // frame the selected tool
  118.     virtual pascal void BuildChoiceArray();            // build tool array
  119.     virtual pascal void Toggle();                    // toggle tool selections
  120.     virtual pascal void DoHighlightSelection(HLState fromHL, HLState toHL);
  121.  
  122. //    FIELDS    
  123.     Rect     fChoiceArray[kLightsInPalette];            // tool array
  124.     eLights    fCurrentTool;                            // tool selection
  125.     eLights    fOldTool;                                // earlier used tool
  126.     eLights    fSelectedTool;                            // currently *selected* tool                        
  127. };
  128.  
  129.  
  130. // TCOMMANDS ------------------------------------------------------------------
  131.  
  132. class TToolSelectCommand : public TTearOffMenuViewTracker {
  133. public:
  134. //    METHODS
  135.     virtual pascal void     IToolSelectCommand (TLightPalette*     theToolsPalette,
  136.                                                  TLightPalette*    theMenuToolsPalette,
  137.                                                 TLightPalette*     theFloatingToolsPalette,
  138.                                                 VPoint&         theMouse);
  139.                                             
  140.     virtual pascal  void     DoIt(void);                // execute selection command
  141.     virtual Boolean pascal    IsDoneTracking();        // no more tracking?
  142.  
  143.     virtual pascal    void    TrackFeedback       (TrackPhase         aTrackPhase,
  144.                                                 const VPoint&    anchorPoint,
  145.                                                 const VPoint&    previousPoint,
  146.                                                 const VPoint&    nextPoint,
  147.                                                 Boolean            mouseDidMove,
  148.                                                 Boolean            turnItOn);
  149.                                                 
  150.     virtual pascal TTracker* TrackMouse           (TrackPhase         aTrackPhase,
  151.                                                 VPoint&            anchorPoint,
  152.                                                 VPoint&            previousPoint,
  153.                                                 VPoint&            nextPoint,
  154.                                                 Boolean            mouseDidMove);
  155.                                                 
  156. //    FIELDS                                                
  157.     eLights            fTool;                            // selected tool
  158.     TLightPalette*    fMenuToolsPalette;                // ptr to Menu Tool view
  159.     TLightPalette*    fFloatingToolsPalette;            // ptr to Floating WIndow view
  160.     Boolean            fExitTracking;                    // keep track of tracking state
  161. };
  162.  
  163.  
  164. class TTrafficCommand : public TCommand {
  165. public:
  166. //    METHODS
  167.     TWindoidDocument* fCommandDocument;                // document attached to command
  168. };
  169.  
  170.  
  171. class TGreenCommand : public TTrafficCommand {
  172. public:
  173. //    METHODS
  174.     virtual pascal void IGreenCommand(TWindoidDocument*);
  175.     virtual pascal void DoIt();
  176. };
  177.  
  178.  
  179. class TYellowCommand : public TTrafficCommand {
  180. public:
  181. //    METHODS
  182.     virtual pascal void IYellowCommand(TWindoidDocument*);
  183.     virtual pascal void DoIt();
  184. };
  185.  
  186.  
  187. class TRedCommand : public TTrafficCommand {
  188. public:
  189. //    METHODS
  190.     virtual pascal void IRedCommand(TWindoidDocument*);
  191.     virtual pascal void DoIt();
  192. };
  193.  
  194.  
  195. // THE END -------------------------------------------------------------------
  196.